import React from 'react'
import { BrowserRouter, Route, Switch, Redirect } from 'react-router-dom'
import Login from '../Login'
import Registry from '../Registry'
import Main from '../Main'
import Personal from '../Personal'
import PersonalUpdate from '../PersonalUpdate'
import Create from '../Create'
import ArticleDetails from '../ArticleDetails'
import ArticleSet from '../ArticleSet'

class App extends React.Component {
  render() {
    return (
      <BrowserRouter>
        {/* 根据URL路径匹配路由组件，渲染到该位置 */}
        <Switch>
          <Route path="/login" component={Login} />
          <Route path="/registry" component={Registry} />
          <Route path="/main/:id" component={Main} />
          <Route path="/personal/:id" component={Personal} />
          <Route path="/personalUpdate/:id" component={PersonalUpdate} />
          <Route path="/create/:id" component={Create} />
          <Route path="/articleDetail/:id" component={ArticleDetails} />
          <Route path="/articleSet/:id" component={ArticleSet} />
          <Redirect from="/" to="/login" exact />
          {/* 这是一个默认页面，如果前面的路由都没有被匹配到，就会渲染这个组件，相当于404，一定要放到最后 */}
          {/*<Route component={} />*/}
        </Switch>
      </BrowserRouter>
    )
  }
}

export default App
